package ca.llsutherland.squash.domain;

import java.io.Serializable;

public abstract class DomainObject implements Serializable, Comparable<DomainObject>{

    private static final long serialVersionUID = 1L;

    private Long id;

    private Clock dateCreated;

    private Clock dateUpdated;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }
    
    @Override
    public int hashCode() {
        return this.getId().hashCode();
    }
    

    @Override
    public int compareTo(DomainObject o) {
        return this.getId().compareTo(o.getId());
    }

    @Override
    public boolean equals(Object obj) {
        DomainObject d1 = (DomainObject)obj;
        return this.id.equals(d1.getId());
    }

    public void setDateCreated(Clock dateCreated) {
        this.dateCreated = dateCreated;
    }

    public Clock getDateCreated() {
        return dateCreated;
    }

    public Clock getDateUpdated() {
        return dateUpdated;
    }

    public void setDateUpdated(Clock dateUpdated) {
        this.dateUpdated = dateUpdated;
    }
}
